package app.webchat.payments.agree.utils;

import android.util.Log;

import java.util.ArrayList;
import java.util.List;

import app.webchat.payments.agree.event.WXPayResultListener;
import app.webchat.payments.agree.event.WXPayResulter;

/**
 * Created by zhujinzhujin
 * on 2017/1/12.
 */

public class WXPayResultManager implements WXPayResulter {

    private static final String TAG = "WXPayResultManager";

    private static WXPayResultManager wxPayResultManager;

    public static WXPayResultManager Instener(){
        if(null == wxPayResultManager){
            wxPayResultManager = new WXPayResultManager();
        }
        return wxPayResultManager;
    }

    private WXPayResultManager(){

    }

    private List<WXPayResultListener> list = new ArrayList<WXPayResultListener>();

    @Override
    public void addWatcher(WXPayResultListener listener) {
        Log.i(TAG, "addWatcher");
        list.add(listener);
    }

    @Override
    public void removeWatcher(WXPayResultListener listener) {
        Log.i(TAG, "removeWatcher");
        list.remove(listener);
    }

    @Override
    public void notifyWatchers() {
        Log.i(TAG, "notifyWatchers");
        for(WXPayResultListener listener : list) {
            listener.payFinish();
        }
    }

}
